<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>javascript</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box
    }
    body {
      font-size: 14px;
      padding: 20px;
    }
    ul li {
      line-height: 30px;
    }
  </style>
</head>
<body>
  <ul>
    <li></li>
  </ul>
</body>
<script>
  function* helloWorldGenerator() {
    yield 'hello';
    yield 'world'
    return 'ending'
  }
  var h = helloWorldGenerator();
  console.dir(h);
  console.log(h.next())
  console.log(h.next())
  console.log(h.next())
  console.log(h.next())
  function* test() {
    console.log(('111'))
    yield '我是什么'
    yield '我是扎你'
    return '你知道了吧'
  }
  var t = test();
  let time = setInterval(() => {
    let v = t.next();
    console.log(v.value);
    if (v.done) {
      clearInterval(time);
      return;
    }
  }, 2000);
</script>
</html>